package com.ruoyi.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysWithdrawal;
import com.ruoyi.project.system.service.ISysWithdrawalService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 申请提现Controller
 * 
 * @author jjp
 * @date 2020-04-17
 */
@RestController
@Api(description = "申请提现Controller")
@RequestMapping("/system/withdrawal")
public class SysWithdrawalController extends BaseController
{
    @Autowired
    private ISysWithdrawalService sysWithdrawalService;

    /**
     * 查询申请提现列表
     */
    @PreAuthorize("@ss.hasPermi('system:withdrawal:list')")
    @ApiOperation("查询申请提现列表")
    @GetMapping("/list")
    public TableDataInfo list(SysWithdrawal sysWithdrawal)
    {
        startPage();
        List<SysWithdrawal> list = sysWithdrawalService.selectSysWithdrawalList(sysWithdrawal);
        return getDataTable(list);
    }



    /**
     * 获取申请提现详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:withdrawal:query')")
    @ApiOperation("获取申请提现详细信息")
    @GetMapping(value = "/{withdrawalId}")
    public AjaxResult getInfo(@PathVariable("withdrawalId") Long withdrawalId)
    {
        return AjaxResult.success(sysWithdrawalService.selectSysWithdrawalById(withdrawalId));
    }

    /**
     * 新增申请提现
     */
    @PreAuthorize("@ss.hasPermi('system:withdrawal:add')")
    @ApiOperation("新增申请提现")
    @Log(title = "申请提现", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysWithdrawal sysWithdrawal)
    {
        return toAjax(sysWithdrawalService.insertSysWithdrawal(sysWithdrawal));
    }

    /**
     * 修改申请提现
     */
    @PreAuthorize("@ss.hasPermi('system:withdrawal:edit')")
    @ApiOperation("修改申请提现")
    @Log(title = "申请提现", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysWithdrawal sysWithdrawal)
    {
        return toAjax(sysWithdrawalService.updateSysWithdrawal(sysWithdrawal));
    }

    /**
     * 删除申请提现
     */
    @PreAuthorize("@ss.hasPermi('system:withdrawal:remove')")
    @ApiOperation("删除申请提现")
    @Log(title = "申请提现", businessType = BusinessType.DELETE)
	@DeleteMapping("/{withdrawalIds}")
    public AjaxResult remove(@PathVariable Long[] withdrawalIds)
    {
        return toAjax(sysWithdrawalService.deleteSysWithdrawalByIds(withdrawalIds));
    }

    /**
     * 模糊查询申请提现列表
     */
    @ApiOperation("模糊查询申请提现列表")
    @GetMapping("/getWithdrawal")
    public TableDataInfo getWithdrawal(SysWithdrawal sysWithdrawal)
    {
        startPage();
        List<SysWithdrawal> list = sysWithdrawalService.selectSysWithdrawal(sysWithdrawal);
        return getDataTable(list);
    }
}
